package com.app.view.component.dialogs.createRoom 
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flash.events.MouseEvent;
	
	import org.component.ComboBox;
	import org.component.events.ListEvent;
	
	import com.peachcastle.core.Display;
	
	import com.app.model.data.UserData;
	
	/**
	 * ...
	 * @author kevin
	 */
	public class Form extends Display
	{
		private var _userData:UserData = null;
		
		private var _name:TextField = null;
		private var _minPour:ComboBox = null;
		private var _minPourData:String = null;
		
		public function Form(ui:MovieClip, data:UserData) 
		{
			_userData = data;
			super(ui);
		}
		
		override protected function initialization():void 
		{
			super.initialization();
			
			_name = assest["txt_name"];
			
			var defaultMinPourList:Array = [10, 20, 50];
			var minPourList:Array = [];
			if (_userData.chips)
			{
				var c:int = Math.floor(_userData.chips / 600);
				var len:int = defaultMinPourList.length;
				for (var i :int  = 0; i < len; i++)
				{
					if (defaultMinPourList[i] <= c)
					{
						minPourList.push(String(defaultMinPourList[i]));
					}else
					{
						break;
					}
				}
				
			}
			_minPour = new ComboBox(assest["cb_min_pour"], minPourList);
			_minPourData = minPourList[0];
		}
		
		override protected function configEventListeners():void 
		{
			super.configEventListeners();
			_minPour.addEventListener(ListEvent.LIST_SELECT, onMinPourClick);
		}
		
		private function onMinPourClick(e:ListEvent):void
		{
			_minPourData = e.data;
			trace("onMinPourClick : " + e.data);
		}
		
		public function get name():String
		{
			return _name.text;
		}
		
		public function get minPour():String
		{
			return _minPourData;
		}
	}

}